<?php
// 遍历模块
// 修改名称,和分区名称


$sum = array();
$sql = "SELECT count(*) as count FROM `zone_modul_tb`;";
my_mysql_query($sql, $sum);
$sum = $sum[0]['count'];

$count = @$_GET['count'];
if ($count < 1) {
    $count = 10;
}

$page = @$_GET['page'];
if ($page < 0){
    $page = 0;
} elseif ($page > ceil($sum/$count)) {
    $page = floor($sum/$count);
}
$data = array();
$sql = "SELECT zid,parentid,title,intro,status FROM `zone_modul_tb` LIMIT ".($page*$count).",{$count};";
my_mysql_query($sql, $data)
?>

<style type="text/css">
#table{
    text-align: center;
}
#table1{
    padding-left: 50px;
    text-align: center;
    border-bottom: 1px solid rgb(210,210,210);
}
#table1 input {
    width: 200px;
    height: 20px;
    outline: none;
}
#table td,#table th,
#table1 td,#table1 th{
    padding: 0 15px;
}

#table tr:nth-child(even){
    border-bottom: 1px dotted rgb(210,210,210);
}
.red a:link{
    color: red;
    text-decoration:none;
}
.green a:link{
    color: green;
    text-decoration:none;
}
a:visited{
    text-decoration:none;
}
a:active{
    text-decoration:underline;
}
a:hover {
    text-decoration:underline;
}
td button {
    width: 79px;
    height: 32px;
    color: white;
    font-size: 14px;
    border:none;
    outline:none;
    cursor:pointer;
    background: url(image/agree.png) 0 0 no-repeat;
}
</style>

<table id="table" cellspacing="0">
    <caption><h1>版块</h1></caption>
    <tr>
        <th>序号</th>
        <th>版块ID</th>
        <th>父版块ID</th>
        <th>名称</th>
        <th>简介</th>
        <th>管理员</th>
    </tr>

    <?php

    if ($sum > 0){
        $i=1;
        foreach($data as $modul){
            echo '<tr>';
            echo '<td>'.$i++.'</td>';
            echo '<td>'.$modul['zid'].'</td>';
            echo '<td>'.$modul['parentid'].'</td>';
            echo '<td>'.$modul['title'].'</td>';
            echo '<td>'.$modul['intro'].'</td>';

            echo '<td>';
            if ($modul['status']) {
                echo '<a href="zone_modul_handler.php?action=disable&zid='.$modul['zid'].'">停用模块</a>';
            } else {
                echo '<a href="zone_modul_handler.php?action=enabled&zid='.$modul['zid'].'">激活模块</a>';
            }
            echo '</td>';

            echo '</tr>';
        }
    }
    ?>
</table>

<div class="toolbar">
    <form action="index.php" method="GET">
        <input type="hidden" name="action" value="<?php echo $action; ?>">
        共有<?php echo ceil($sum/$count);?>页,每页有
        <input type="text" size="3" name="count" value="<?php echo $count; ?>">条信息
        当前第<?php echo ($page+1);?>页,跳到第
        <input type="text" size="3" name="page" value="<?php echo $page+2; ?>">页
        <input type="submit" value="GO">
    </form>
</div>
